package Day2025_03_02;

public class LeetCode0102 {
    public boolean CheckPermutation(String s1, String s2) {
        int n1 = s1.length();
        int n2 = s2.length();
        if (n1 != n2) return false;
        int[] hash1 = new int[26];
        int[] hash2 = new int[26];
        for (int i = 0; i < n1; i++) {
            char ch = s1.charAt(i);
            hash1[ch - 'a']++;
        }
        int ret = n1;
        for (int i = 0; i < n2; i++) {
            char tmp = s2.charAt(i);
            int in = tmp - 'a';
            hash2[in]++;
            if (hash2[in] <= hash1[in]) ret--;
        }
        if (ret == 0) return true;
        return false;
    }
}
